package com.lz.hotel_java.mapper;

import com.lz.hotel_java.entity.Room;
import org.apache.ibatis.annotations.*;
import java.util.List;

@Mapper
public interface RoomMapper {
    @Select("SELECT * FROM Room WHERE RoomID = #{roomId}")
    Room selectById(Integer roomId);

    @Select("SELECT * FROM Room")
    List<Room> selectAll();

    @Insert("INSERT INTO Room(RoomNumber, RoomType, Price, Status) VALUES(#{roomNumber}, #{roomType}, #{price}, #{status})")
    @Options(useGeneratedKeys = true, keyProperty = "roomID")
    int insert(Room room);

    @Update("UPDATE Room SET RoomNumber = #{roomNumber}, RoomType = #{roomType}, Price = #{price}, Status = #{status} WHERE RoomID = #{roomId}")
    int update(Room room);

    @Delete("DELETE FROM Room WHERE RoomID = #{roomId}")
    int deleteById(Integer roomId);

    @Update("UPDATE Room SET Status = #{status} WHERE RoomID = #{roomId}")
    int updateStatus(@Param("status") String status, @Param("roomId") Integer roomId);
}
